package org.holynite.fieldmanage.managed.model

import org.holynite.fieldmanage.ejbs.ChargeManagement
import org.holynite.fieldmanage.entities.ChargeScheme

import javax.annotation.PostConstruct
import javax.ejb.EJB
import javax.faces.bean.ManagedBean
import javax.faces.bean.SessionScoped

/**
 * Created by midnite on 15/1/31.
 */
@ManagedBean
@SessionScoped
class ChargeSchemesBean implements Serializable {
    List<ChargeScheme> schemes

    @EJB(beanName = "chargeControl")
    ChargeManagement chargeService

    ChargeSchemesBean() {
        schemes = []
    }

    @PostConstruct
    void initiate() {
        schemes = chargeService.findSchemes("")
    }

    ChargeScheme findScheme(String schemeId) {
        schemes.find { it.schemeId.equals(schemeId) }
    }
}
